<?php
/**
 分类删除功能
 */
//获取分类Id
$categoryId = $_GET['category_id'];

//检测分类Id
if (empty($categoryId)){
    echo "分类id错误";
    exit();
}

//连接到数据库
$dsn = "mysql:host=127.0.0.1;dbname=blog";
$db = new PDO($dsn, "root", "123456");

//php语句mysql删除数据
$sql = "delete from category where category_id='$categoryId'";
$result = $db->exec($sql);
if ($result){
    echo "删除分类成功。<a href='category_list.php'>返回分类列表页</a>>";
    exit();
}else{
    echo "删除分类失败。错误信息：".$db->errorInfo()[2].",请联系管理员123 ";
}